package com.zyl.musicdemo.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.zyl.musicdemo.R;

public class BaseActivity extends AppCompatActivity {

    ImageView ivBack, ivUser;
    TextView tvTitle;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    protected void initNavBar(boolean isBack, String titleStr, boolean isUser) {
        ivBack = findViewById(R.id.iv_back);
        ivUser = findViewById(R.id.iv_user);
        tvTitle = findViewById(R.id.tv_title);

        tvTitle.setText(titleStr);

        ivBack.setVisibility(isBack ? View.VISIBLE : View.GONE);
        ivUser.setVisibility(isUser ? View.VISIBLE : View.GONE);

        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        ivUser.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toUser();
            }
        });
    }

    private void toUser() {
        Intent intent = new Intent(this, UserActivity.class);
        startActivity(intent);
    }
}
